<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <?php
        session_start();
        if(isset($_POST['option']))
        {
            include("../Service/WebClass/timer/CampaignTimerService.php");

            $CampaignTimerService = new CampaignTimerService();

            if($CampaignTimerService->updateTimer())
            {
                $message = "更新しました。";
            }
            else
            {
                $message = "更新失敗しました。";
            }
            echo "<script language='javascript'>alert(\"".$message."\");</script>";
        }
    ?>
    <title>タイマー設定</title>
    <link rel="stylesheet" href="../css/common.css" type="text/css" />
    <script language="JavaScript" src="../js/common.js" type="text/javascript"></script>
    <script language="JavaScript" src="../js/InputCheck.js" type="text/javascript"></script>
    <script language="JavaScript" src="../js/Calendar4.js" type="text/javascript"></script>
    <meta http-equiv="Pragma" content="cache">
    <meta http-equiv="Cache-Control" content="cache">
</head><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    </form>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="logo" id="topmenu">
        <tr>
            <td width="200" valign="top">&nbsp;</td>
            <td align="right" valign="top">
                <br>
                <input type="button" class="btn close" onClick="self.close();">
            </td>
        </tr>
    </table>
    <br><br>
    <form name="inputform" method="post">
    <input type="hidden" name="option" value=""/>
        <div>
            <table border="0" cellpadding="2" cellspacing="0" width="100%">
                <tbody>
                    <tr>
                        <td align="right"><input class="btn save" value="" type="submit" onclick="return campaign_timer_check()"></td></td>
                    </tr>
                </tbody>
            </table>
            <table class="tbl" border="0" cellpadding="4" cellspacing="0" width="100%">
                <tbody><tr>
                        <td class="td9" align="left" width="200">
                            タイマーID
                        </td>
                        <td class="td4 left"><?php echo $_GET['timerId'];?></td>
                    </tr>
                    <tr>
                        <td class="td9 top" align="left" width="200">
                            タイマー実行
                        </td>
                        <td class="td4 border">
                            <input name="timerFlg" id="timer_status1" value="1" checked="checked" type="radio"><label for="timer_status1">オン</label>

                            <input name="timerFlg" id="timer_status0" value="0" type="radio"><label for="timer_status0">オフ</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="td9 top" align="left">日時</td>
                        <td class="td4 border">
                            <input name="timerType" id="timer_type1" value="0" checked="checked" type="radio">
                            <label for="timer_type1">毎日</label>&nbsp;&nbsp;

                            <select name="timerTime0" class="txBox">
                                <option value="0" selected="selected">00時
                                </option><option value="1">01時
                                </option><option value="2">02時
                                </option><option value="3">03時
                                </option><option value="4">04時
                                </option><option value="5">05時
                                </option><option value="6">06時
                                </option><option value="7">07時
                                </option><option value="8">08時
                                </option><option value="9">09時
                                </option><option value="10">10時
                                </option><option value="11">11時
                                </option><option value="12">12時
                                </option><option value="13">13時
                                </option><option value="14">14時
                                </option><option value="15">15時
                                </option><option value="16">16時
                                </option><option value="17">17時
                                </option><option value="18">18時
                                </option><option value="19">19時
                                </option><option value="20">20時
                                </option><option value="21">21時
                                </option><option value="22">22時
                                </option><option value="23">23時
                            </option></select>

                            <br><br>
                            <input name="timerType" id="timer_type2" value="1" type="radio">
                            <label for="timer_type2">毎週</label>&nbsp;&nbsp;
                            <input name="Sun" value="1" id="week_1" type="checkbox"><label for="week_1">日</label>
                            <input name="Mon" value="2" id="week_2" type="checkbox"><label for="week_2">月</label>
                            <input name="Tue" value="3" id="week_3" type="checkbox"><label for="week_3">火</label>

                            <input name="Wed" value="4" id="week_4" type="checkbox"><label for="week_4">水</label>
                            <input name="Thu" value="5" id="week_5" type="checkbox"><label for="week_5">木</label>
                            <input name="Fri" value="6" id="week_6" type="checkbox"><label for="week_6">金</label>
                            <input name="Sat" value="7" id="week_7" type="checkbox"><label for="week_7">土</label>
                            &nbsp;
                            <select name="timerTime1" class="txBox">
                                <option value="0" selected="selected">00時
                                </option><option value="1">01時
                                </option><option value="2">02時
                                </option><option value="3">03時
                                </option><option value="4">04時
                                </option><option value="5">05時
                                </option><option value="6">06時
                                </option><option value="7">07時
                                </option><option value="8">08時
                                </option><option value="9">09時
                                </option><option value="10">10時
                                </option><option value="11">11時
                                </option><option value="12">12時
                                </option><option value="13">13時
                                </option><option value="14">14時
                                </option><option value="15">15時
                                </option><option value="16">16時
                                </option><option value="17">17時
                                </option><option value="18">18時
                                </option><option value="19">19時
                                </option><option value="20">20時
                                </option><option value="21">21時
                                </option><option value="22">22時
                                </option><option value="23">23時
                            </option></select>


                            <br><br>
                            <input name="timerType" id="timer_type3" value="2" type="radio">
                            <label for="timer_type3">一回</label>&nbsp;&nbsp;
                            <input name="timerDate" id="timer_type3_day" value="" class="txBox" style="width: 65px;" type="text">
                            <a href="javascript:void(0)">
                            <img name="popcal2" align="top" src="../images/cal.gif" border="0" alt="calendar" onclick="MyCalendar.SetDate(this,document.getElementById('timer_type3_day'))"></a>&nbsp;
                            <select name="timerTime2" class="txBox">
                                <option value="0" selected="selected">00時
                                </option><option value="1">01時
                                </option><option value="2">02時
                                </option><option value="3">03時
                                </option><option value="4">04時
                                </option><option value="5">05時
                                </option><option value="6">06時
                                </option><option value="7">07時
                                </option><option value="8">08時
                                </option><option value="9">09時
                                </option><option value="10">10時
                                </option><option value="11">11時
                                </option><option value="12">12時
                                </option><option value="13">13時
                                </option><option value="14">14時
                                </option><option value="15">15時
                                </option><option value="16">16時
                                </option><option value="17">17時
                                </option><option value="18">18時
                                </option><option value="19">19時
                                </option><option value="20">20時
                                </option><option value="21">21時
                                </option><option value="22">22時
                                </option><option value="23">23時
                            </option></select>


                        </td>
                    </tr>
                    <tr>
                        <td class="td9 top" align="left" width="200">
                            掲載オン/オフを切り替える
                        </td>
                        <td class="td4 border">

                            <input name="status" id="status1" value="1" type="radio"><label for="status1">オン</label>
                            <input name="status" id="status0" value="0" checked="checked" type="radio"><label for="status0">オフ</label>
                        </td>
                    </tr>
            </tbody></table>
            <?php
                if(!isset($_POST['option']))
                {
                    include("../Service/WebClass/timer/CampaignTimerService.php");

                    $CampaignTimerService = new CampaignTimerService();
                    $CampaignTimerService->Init();
                }

                if($CampaignTimerService->timerFlg == "0")
                {
                    echo "<script>document.inputform.timerFlg[1].checked=true;</script>";
                }
                else
                {
                    echo "<script>document.inputform.timerFlg[0].checked=true;</script>";
                }

                if($CampaignTimerService->timerType == "2")
                {
                    echo "<script>document.inputform.timerType[2].checked=true;</script>";
                    echo "<script>document.inputform.timerDate.value=\"".$CampaignTimerService->timerDate."\";</script>";
                    echo "<script>document.inputform.timerTime2.value=\"".$CampaignTimerService->timerTime."\";</script>";
                }
                else if($CampaignTimerService->timerType == "1")
                {
                    echo "<script>document.inputform.timerType[1].checked=true;</script>";

                    if(strpos($CampaignTimerService->timerWeek,"0") !== False)
                    {
                        echo "<script>document.inputform.Sun.checked=true;</script>";
                    }
                    if(strpos($CampaignTimerService->timerWeek,"1") !== False)
                    {
                        echo "<script>document.inputform.Mon.checked=true;</script>";
                    }
                    if(strpos($CampaignTimerService->timerWeek,"2") !== False)
                    {
                        echo "<script>document.inputform.Tue.checked=true;</script>";
                    }
                    if(strpos($CampaignTimerService->timerWeek,"3") !== False)
                    {
                        echo "<script>document.inputform.Wed.checked=true;</script>";
                    }
                    if(strpos($CampaignTimerService->timerWeek,"4") !== False)
                    {
                        echo "<script>document.inputform.Thu.checked=true;</script>";
                    }
                    if(strpos($CampaignTimerService->timerWeek,"5") !== False)
                    {
                        echo "<script>document.inputform.Fri.checked=true;</script>";
                    }
                    if(strpos($CampaignTimerService->timerWeek,"6") !== False)
                    {
                        echo "<script>document.inputform.Sat.checked=true;</script>";
                    }

                    echo "<script>document.inputform.timerTime1.value=\"".$CampaignTimerService->timerTime."\";</script>";
                }
                else
                {
                    echo "<script>document.inputform.timerType[0].checked=true;</script>";
                    echo "<script>document.inputform.timerTime0.value=\"".$CampaignTimerService->timerTime."\";</script>";
                }

                if($CampaignTimerService->campaignStatus == "0")
                {
                    echo "<script>document.inputform.status[1].checked=true;</script>";
                }
                else
                {
                    echo "<script>document.inputform.status[0].checked=true;</script>";
                }
            ?>
            <br>
        </div>
    </form>

</body>
</html>